from db import db


class HouseInfo(db.Model):
    """
    create table house_info
    (
        id                int auto_increment comment '唯一标识' primary key,
        title             varchar(255) not null comment '房名',
        cover             varchar(255) null comment '图片链接',
        city              varchar(255) not null comment '市区',
        region            varchar(255) null comment '地区',
        address           varchar(255) not null comment '详细地址',
        rooms_desc        varchar(255) null comment '户型',
        area_range        varchar(255) null comment '面积',
        all_ready         varchar(255) null comment '是否预售',
        prices            varchar(255) null comment '每平方米价格',
        house_decoration  varchar(255) null comment '房屋装修情况',
        company           varchar(255) null comment '公司',
        house_type        varchar(255) null comment '房屋类型',
        on_time           varchar(255) null comment '交房时间',
        open_date         varchar(255) null comment '开盘时间',
        tags              varchar(255) null comment '标签',
        total_price_range varchar(255) null comment '总价区间',
        sale_status       varchar(255) null comment '售房情况',
        detail_url        varchar(255) null comment '详情链接'
    )
        comment '房屋信息表';
    """

    __tablename_ = "house_info"

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    title = db.Column(db.String(255), nullable=False)
    cover = db.Column(db.String(2555), nullable=False)
    city = db.Column(db.String(255), nullable=False)
    region = db.Column(db.String(255), nullable=False)
    address = db.Column(db.String(255), nullable=False)
    rooms_desc = db.Column(db.String(255), nullable=False)
    area_range = db.Column(db.String(255), nullable=False)
    all_ready = db.Column(db.String(255), nullable=False)
    prices = db.Column(db.String(255), nullable=False)
    house_decoration = db.Column(db.String(255), nullable=False)
    company = db.Column(db.String(255), nullable=False)
    house_type = db.Column(db.String(255), nullable=False)
    on_time = db.Column(db.String(255), nullable=False)
    open_date = db.Column(db.String(255), nullable=False)
    tags = db.Column(db.String(255), nullable=False)
    total_price_range = db.Column(db.String(255), nullable=False)
    sale_status = db.Column(db.String(255), nullable=False)
    detail_url = db.Column(db.String(255), nullable=False)

    def __str__(self):
        return f"""HouseInfo(id={self.id}, title={self.title}, cover={self.cover}, city={self.city}, region={self.region}, address={self.address}, rooms_desc={self.rooms_desc}, area_range={self.area_range}, all_ready={self.all_ready}, prices={self.prices}, house_decoration={self.house_decoration}, company={self.company}, house_type={self.house_type}, on_time={self.on_time}, open_date={self.open_date}, tags={self.tags}, total_price_range={self.total_price_range}, sale_status={self.sale_status}, detail_url={self.detail_url})"""
